package regex;

/**
 * String类中关于正则的方法:
 *   public String[] split(String regex) :根据正则表达式切割(拆分)字符串
 */
public class RegexDemo07 {

    public static void main(String[] args) {
        //method01();
        //method02();
    }

    private static void method02() {
        //切割ip地址
        String ip = "192.168.1.2";
        String[] splitstrs = ip.split("\\.");
        for (int i = 0; i < splitstrs.length; i++) {
            System.out.println(splitstrs[i]);
        }
    }

    private static void method01() {
        //切割单词
        String str = "I     love   java so much";
        String[] splitstrs = str.split(" +");
        for (int i = 0; i < splitstrs.length; i++) {
            System.out.println(splitstrs[i]);
        }
    }
}
